<?php
class Model_Comment extends Model {
	public  $table="comment";
	//======= Add new user==============	
		public function add_comment($data)
		{
			return $this->insert($this->table,$data);
			
		}
		//====Get news
		public function get_comment($id,$str)
		{	
			
			$sql="select com.* ,user.nhom,user.chuky from comment as com
				left join user on com.user_id=user.id
				where
			 	 com.number_id=$id and com.geturl='".$str."'
		   order by com.id desc";
			$this->query($sql);
		}
		//====Get news chap
		public function get_comment_chap($id)
		{
			$where=array("number_id="=>$id,
						 "geturl="=>"chap");
			$this->where($where);
			return $this->getdata($this->table);
		}
	//=====Login
		public function update_comment($data)
		{
			return $this->update($this->table,$data);
				
		}
		public function delete_comment($id)
		{
			$this->where="id = $id";
			return $this->delete($this->table);
				
		}
		public function quote_comment($id)
		{
			$this->where="id='$id'";
			return $this->getdata($this->table);
				
		}
		public function get_recent()
		{
			$this->limit="0,15";
			$this->order="id desc";
			return $this->getdata($this->table);
				
		}
		//====Get news
		public function get_comment2($id,$str,$num)
		{	
			$this->where="number_id=$id and geturl='".$str."'";
                         $this->limit="0,$num";
                         $this->order="id desc";
			return $this->getdata($this->table);
		}


	
}